<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" CodeBehind="Load.aspx.cs" Inherits="MOM.Load" %>
<%@ Register TagPrefix="Unit" TagName="Rating" Src="~/Units/Rating.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<script type="text/javascript" language="javascript" src="Js/jquery-1.2.6.js"></script>
	<script type="text/javascript" language="javascript" src="Js/jquery.contextmenu.r2.js"></script>		
	<script type="text/javascript" language="javascript" src="Js/Common.js"></script>
	<script type="text/javascript" language="javascript" src="Js/KeyHandler.js"></script>
	<script type="text/javascript" language="javascript" src="Js/Translate_<%=Lang %>.js"></script>
	<script type="text/javascript">
	    var _CurrentTheme = '<%= MOMTheme %>';
	    
		$(document).ready(function() {
			$("#cbMulti").click(function() { var checked_status = this.checked; $(":checkbox").each(function() { this.checked = checked_status; }); }); 
			
			$(".Track").each(
				function (i, n)
				{
					$(this).contextMenu('TrackMenu', 
					{
						menuStyle:{width:'150px'},
						bindings:
						{
							'queue':function() {top.MOM.PlayTracks([parseInt(n.id.substr(6))], false);},
							'queueandplay':function() {top.MOM.PlayTrack(parseInt(n.id.substr(6)));},
							'justplay':function() {top.MOM.PlayTrack(parseInt(n.id.substr(6)));},
							'lyrics':function() {top.MOM.GetLyrics(parseInt(n.id.substr(6)));},
							'videos':function() {top.MOM.GetVideos('<%#CurrentArtist.Name%>',n.innerHTML.split('&nbsp;')[0]);},
							'disable':function() {DisableTrack(parseInt(n.id.substr(6)));}
						}
					});	
				}
			)
			
			$.getJSON("DB/JSON/LastFm.aspx", {ac:"toptracks",a:"<%#CurrentArtist.Name%>"}, TopTracks_Callback);
		});
        
        function TopTracks_Callback(json)
        {
			$(".Filter").each(
				function (i, n)
				{
					var c = 1;
					for (var i = 0; i < json.Result.length; i++)
					{
						if ($(this).text().toLowerCase() == json.Result[i].toLowerCase())
						{
							$(this).html($(this).text() + "&nbsp;<sub>" + c + "</sub>");
						}
						c++;
					}
				}
			);
        }
        
		function SelectTracks(replace)
		{
			var tracks = new Array();
			$(":checkbox").each(			
				function()
				{
					if (parseInt(this.value) > 0 && this.checked && $(this).parent().parent().css("display") != "none")
						tracks.push(parseInt(this.value));
				}
			);
			top.MOM.PlayTracks(tracks, replace);
		}

		function DisableTrack(id)
		{
			$.getJSON("DB/Update.aspx", {a:"trackdisablecheck",id:id}, function (json) {DisableTrack_Callback(json, id);});
		}		
		
		function DisableTrack_Callback(json, id)
		{
			if (confirm(window.Translate.ConfirmDisable(json.Track, json.Share)))
				$.get("DB/Update.aspx", {a:"trackdisable",id:id});				
			
		}
	</script>
	<style type="text/css">
		@import url(Css/Mom.css);
		@import url(Css/themes/<%=MOMTheme %>.css);		
	</style>
</head>
<body class="Iframe">
<form id="Form1" runat="server">
	<div id="TrackMenu" class="contextMenu">
		<ul>
			<li id="queue"><%=Translate("queue") %></li>
			<li id="queueandplay"><%=Translate("queueandplay") %></li>
			<li id="justplay"><%=Translate("justplay") %></li>
			<li id="lyrics"><%=Translate("lyrics") %></li>
			<li id="videos"><%=Translate("videos") %></li>
			<li id="disable"><%=Translate("disabletrack") %></li>
		</ul>
	</div>
	
	<div class="DropShadow" style="margin-right:20px;">
		<div class="Box">
			<div class="P10">
				<h1 class="AlbumView Row"><%#CurrentArtist.Albums[0].Name %></h1>
				<div class="Row">
					<div class="FloatLeft" style="width:250px;padding-top:30px;">
						<img src="Utility/ScaledImage.ashx?cover=<%#CurrentArtist.Albums[0].CoverFront %>&size=250" width="250" height="250" class="AlbumViewCover" />
						<div class="AlbumViewText">
							<span class="AlbumHeader"><a href="Browse.aspx?t=album&id=<%#CurrentArtist.Id %>"><%#CurrentArtist.Name %></a></span>
							<%#CurrentArtist.Genre %> - <%#CurrentArtist.Albums[0].ReleaseYear %>
						</div>
						<div class="ButtonRow">
							<a href="javascript:SelectTracks(false)" class="Button"><%=Translate("queueselected") %></a>
							<a href="javascript:SelectTracks(true)" class="Button"><%=Translate("playselected") %></a>
						</div>													
					</div>
					<table class="AlbumViewTracksContainer" border="0" cellspacing="0" cellpadding="5">
						<thead>						
						</thead>
						<tbody>
							<tr><td colspan="6" align="right"><input type="checkbox" id="cbMulti" value="0" checked="checked" /></td></tr>	
						<asp:Repeater ID="rptTrack" OnItemCreated="Track_Created" runat="server">
							<ItemTemplate>
								<tr onmouseover="Hover(this)" onmouseout="Hover(this)">
									<td valign="top"><%#Container.ItemIndex + 1 %>.</td>
									<td valign="top"><a href="javascript:void(0);" onclick="top.MOM.PlayTrack(<%#Eval("Id") %>);" class="Track Filter" id="Track_<%#Eval("Id") %>"><%#Eval("Name") %></a><asp:PlaceHolder ID="plhTrackArtist" Visible='<%#!CurrentArtist.Name.Equals(Eval("TrackArtist")) %>' runat="server"><span class="TrackArtist"><%#Eval("TrackArtist") %></span></asp:PlaceHolder></td>
									<td valign="top"><%#Eval("DurationString") %></td>
									<td valign="top"><%#Eval("PlayCount") %></td>
									<td><Unit:Rating TrackId='<%#Eval("Id") %>' Rating='<%#Eval("Rating") %>' runat="server" /></td>
									<td><input type="checkbox" id="cbSelect" value='<%#Eval("Id") %>' runat="server" /></td>
								</tr>
							</ItemTemplate>
						</asp:Repeater>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>	
</form>
</body></html>